<?php
    require  "../init.php";

    if(empty($_SESSION['admin'])){
        admin_redirect("请登录",3,ADMIN_ROOT_URL . "login.php");
        die;
    }

    $type = $_SESSION['admin']['type'];
    //0是超级管理员,1是普通管理员
    if(($type != 0) && ($type != 1)){
        admin_redirect("您的权限不足,不能进行该操作");
        die;
    }

    $sql = "select id,path,cname,concat(path,id,',') as bpath from ". PRE ."category order by bpath";

    $res = query($link,$sql);



?>

<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Creative - Bootstrap 3 Responsive Admin Template">
    <meta name="author" content="GeeksLabs">
    <meta name="keyword" content="Creative, Dashboard, Admin, Template, Theme, Bootstrap, Responsive, Retina, Minimal">
    <link rel="icon" href="../../public/admin/img/icons/logo.jpg">

    <title>小米 后台(添加商品)</title>

    <!-- Bootstrap CSS -->
    <link href="../../public/admin/css/bootstrap.min.css" rel="stylesheet">
    <!-- bootstrap theme -->
    <link href="../../public/admin/css/bootstrap-theme.css" rel="stylesheet">
    <!--external css-->
    <!-- font icon -->
    <link href="../../public/admin/css/elegant-icons-style.css" rel="stylesheet" />
    <link href="../../public/admin/css/font-awesome.min.css" rel="stylesheet" />
    <!-- full calendar css-->
    <link href="../../public/admin/assets/fullcalendar/fullcalendar/bootstrap-fullcalendar.css" rel="stylesheet" />
    <link href="../../public/admin/assets/fullcalendar/fullcalendar/fullcalendar.css" rel="stylesheet" />
    <!-- easy pie chart-->
    <link href="../../public/admin/assets/jquery-easy-pie-chart/jquery.easy-pie-chart.css" rel="stylesheet" type="text/css" media="screen"/>
    <!-- owl carousel -->
    <link rel="stylesheet" href="../../public/admin/css/owl.carousel.css" type="text/css">
    <link href="../../public/admin/css/jquery-jvectormap-1.2.2.css" rel="stylesheet">
    <!-- Custom styles -->
    <link rel="stylesheet" href="../../public/admin/css/fullcalendar.css">
    <link href="../../public/admin/css/widgets.css" rel="stylesheet">
    <link href="../../public/admin/css/style.css" rel="stylesheet">
    <link href="../../public/admin/css/style-responsive.css" rel="stylesheet" />
    <link href="../../public/admin/css/xcharts.min.css" rel=" stylesheet">
    <link href="../../public/admin/css/jquery-ui-1.10.4.min.css" rel="stylesheet">
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 -->
    <!--[if lt IE 9]>
    <script src="../../public/admin/js/html5shiv.js"></script>
    <script src="../../public/admin/js/respond.min.js"></script>
    <script src="../../public/admin/js/lte-ie7.js"></script>
    <![endif]-->
</head>

<body>
<!-- container section start -->
<section id="container" class="">
    <!--引入头部-->
    <?php require '../top.php'?>
    <!--引入左边菜单栏-->
    <?php require '../aside.php'?>

    <!--main content start-->
    <section id="main-content">
        <section class="wrapper">

            <div class="row">
                <div class="col-lg-12">
                    <section class="panel">
                        <header class="panel-heading">
                            添加商品
                        </header>
                        <div class="panel-body">
                            <div class="form">
                                <form class="form-validate form-horizontal " id="register_form" method="post" action="action.php?act=add" enctype="multipart/form-data">
                                    <div class="form-group ">
                                        <label for="gname" class="control-label col-lg-2">商品名 <span class="required">*</span></label>
                                        <div class="col-lg-10">
                                            <input class=" form-control" id="gname" name="gname" type="text" />
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="cate_id" class="control-label col-lg-2">商品分类 <span class="required">*</span></label>
                                        <div class="col-lg-10">
                                            <select name="cate_id" class=" form-control">
                                                <?php if(!empty($res)):?>
                                                    <?php foreach($res as $value):?>
                                                        <option value="<?php echo $value['id']?>">
                                                            <?php echo str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;",
                                                                    substr_count($value['path'],","))."->".
                                                          $value['cname']?></option>
                                                    <?php endforeach;?>
                                                <?php endif;?>
                                            </select>
                                        </div>

                                    </div>

                                    <div class="form-group ">
                                        <label for="price" class="control-label col-lg-2">价格 <span class="required">*</span></label>
                                        <div class="col-lg-10">
                                            <input class=" form-control" id="price" name="price" type="number" />
                                        </div>
                                    </div>

                                    <div class="form-group ">
                                        <label for="is_new" class="control-label col-lg-2">是否是新品 <span class="required">*</span></label>
                                        <div class="col-lg-10">
                                            <label class="radio-inline">
                                                <input type="radio" name="is_new" id="is_new" value="1"> 是
                                            </label>
                                            <label class="radio-inline">
                                                <input type="radio" name="is_new" id="is_new" checked value="0"> 否
                                            </label>
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="is_hot" class="control-label col-lg-2">是否是热销 <span class="required">*</span></label>
                                        <div class="col-lg-10">
                                            <label class="radio-inline">
                                                <input type="radio" name="is_hot" id="is_hot" value="1"> 是
                                            </label>
                                            <label class="radio-inline">
                                                <input type="radio" name="is_hot" id="is_hot" checked value="0"> 否
                                            </label>
                                        </div>
                                    </div>

                                    <div class="form-group ">
                                        <label for="state" class="control-label col-lg-2">是否上架 <span class="required">*</span></label>
                                        <div class="col-lg-10">
                                            <label class="radio-inline">
                                                <input type="radio" name="state" id="state" value="1"> 上架
                                            </label>
                                            <label class="radio-inline">
                                                <input type="radio" name="state" id="state" checked value="0"> 下架
                                            </label>
                                        </div>
                                    </div>

                                    <div class="form-group ">
                                        <label for="msg" class="control-label col-lg-2">商品图片 <span class="required">*</span></label>
                                        <div class="col-lg-10">
                                            <input type="file" name="gimg">
                                        </div>
                                    </div>


                                    <div class="form-group ">
                                        <label for="msg" class="control-label col-lg-2">商品信息 <span class="required">*</span></label>
                                        <div class="col-lg-10">
                                            <textarea name="msg"  class="form-control" rows="5"></textarea>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <div class="col-lg-offset-2 col-lg-10">
                                            <button class="btn btn-primary" type="submit">提交</button>
                                            <button class="btn btn-default" type="reset">重置</button>
                                            <a href="<?php $_SERVER['HTTP_REFERER']?>"><button class="btn btn-info pull-right" type="button">取消添加</button></a>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </section>
                </div>
            </div>
            <!-- page end-->
        </section>
    </section>
    <!--main content end-->

</section>
<!-- container section start -->

<!-- javascripts -->
<script src="../../public/admin/js/jquery.js"></script>
<script src="../../public/admin/js/jquery-ui-1.10.4.min.js"></script>
<script src="../../public/admin/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="../../public/admin/js/jquery-ui-1.9.2.custom.min.js"></script>
<!-- bootstrap -->
<script src="../../public/admin/js/bootstrap.min.js"></script>
<!-- nice scroll -->
<script src="../../public/admin/js/jquery.scrollTo.min.js"></script>
<script src="../../public/admin/js/jquery.nicescroll.js" type="text/javascript"></script>
<!-- charts scripts -->
<script src="../../public/admin/assets/jquery-knob/js/jquery.knob.js"></script>
<script src="../../public/admin/js/jquery.sparkline.js" type="text/javascript"></script>
<script src="../../public/admin/assets/jquery-easy-pie-chart/jquery.easy-pie-chart.js"></script>
<script src="../../public/admin/js/owl.carousel.js" ></script>
<!-- jQuery full calendar -->
<<script src="../../public/admin/js/fullcalendar.min.js"></script> <!-- Full Google Calendar - Calendar -->
<script src="../../public/admin/assets/fullcalendar/fullcalendar/fullcalendar.js"></script>
<!--script for this page only-->
<script src="../../public/admin/js/calendar-custom.js"></script>
<script src="../../public/admin/js/jquery.rateit.min.js"></script>
<!-- custom select -->
<script src="../../public/admin/js/jquery.customSelect.min.js" ></script>
<script src="../../public/admin/assets/chart-master/Chart.js"></script>

<!--custome script for all page-->
<script src="../../public/admin/js/scripts.js"></script>
<!-- custom script for this page-->
<script src="../../public/admin/js/sparkline-chart.js"></script>
<script src="../../public/admin/js/easy-pie-chart.js"></script>
<script src="../../public/admin/js/jquery-jvectormap-1.2.2.min.js"></script>
<script src="../../public/admin/js/jquery-jvectormap-world-mill-en.js"></script>
<script src="../../public/admin/js/xcharts.min.js"></script>
<script src="../../public/admin/js/jquery.autosize.min.js"></script>
<script src="../../public/admin/js/jquery.placeholder.min.js"></script>
<script src="../../public/admin/js/gdp-data.js"></script>
<script src="../../public/admin/js/morris.min.js"></script>
<script src="../../public/admin/js/sparklines.js"></script>
<script src="../../public/admin/js/charts.js"></script>
<script src="../../public/admin/js/jquery.slimscroll.min.js"></script>
<script>

    //knob
    $(function() {
        $(".knob").knob({
            'draw' : function () {
                $(this.i).val(this.cv + '%')
            }
        })
    });

    //carousel
    $(document).ready(function() {
        $("#owl-slider").owlCarousel({
            navigation : true,
            slideSpeed : 300,
            paginationSpeed : 400,
            singleItem : true

        });
    });

    //custom select box

    $(function(){
        $('select.styled').customSelect();
    });

    /* ---------- Map ---------- */
    $(function(){
        $('#map').vectorMap({
            map: 'world_mill_en',
            series: {
                regions: [{
                    values: gdpData,
                    scale: ['#000', '#000'],
                    normalizeFunction: 'polynomial'
                }]
            },
            backgroundColor: '#eef3f7',
            onLabelShow: function(e, el, code){
                el.html(el.html()+' (GDP - '+gdpData[code]+')');
            }
        });
    });



</script>

</body>
</html>